package com.base.controller;

import java.util.Date;
import java.util.UUID;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.base.entity.Member;
import com.base.entity.User;

@RestController
public class RabbitMqController {

	@Autowired
	private RabbitTemplate rabbitTemplate;
	
	@GetMapping("/send")
	public String send() {
		
		User message = new User();
		message.setUserId(11L);
		message.setUserName("测试");
		message.setNowDate(new Date());
		rabbitTemplate.convertAndSend("java.direct.exchange","java",message,new CorrelationData(UUID.randomUUID().toString()));
	
		Member member = new Member();
		member.setMemberId(22L);
		member.setMemberName("会员");
		rabbitTemplate.convertAndSend("java.direct.exchange","java2",member,new CorrelationData(UUID.randomUUID().toString()));
	
		
		return "OK";
	}
	
}
